<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>短信登入</title>
  <script src="webjars/jquery/3.4.1/jquery.js" type="text/javascript"></script>
</head>
<body>
<form  action="/duanxin/login" method="post">
    手机号码:<input type="text" name="phone" id="phone"><br/>
    发送验证码:<input type="text" name="code">
    <button type="button" onclick="send()">发送验证码</button><br/>
    <input type="submit" value="登入">
</form>
</body>
<script type="text/javascript">
    // function login() {
    //     $.ajax({
    //         url:"http://localhost:8080/duanxin/login",
    //         type:"post",
    //         data:$("#form1").serialize(),
    //         dataType:"json",
    //         success:function (result) {
    //             console.log(result)
    //         }
    //     })
    // }
    //发送验证码
    function send() {
        var phone=$("#phone").val();
        $.ajax({
            url:"http://localhost:8080/duanxin/sendCode",
            type:"post",
            data:{
                "phone": phone
            },
            dataType:"json",
            success:function (result) {
                if(result.type==1){
                    alert("发送成功！")
                    // window.location.href="http://localhost:8080/duanxin/suceess.html";
                }
            }
        })

    }



</script>
</html>